#include "loadImageTexture.h"
#include "loadDDSTexture.h"
#include "ByteBuffer.h"

GLuint LoadDDSTexture(const char* path)
{
	vglImageData image;
	vglLoadImage("pic.dds", &image);
	return vglLoadTexture(&image);
}

GLuint LoadTexture(const char* path)
{
	ByteBuffer bufData(path);
	return LoadTexture(bufData);
}
GLuint LoadTexture(ByteBuffer& bufData)
{
    byte* header = bufData.data();

    if (memcmp(header, PNG_SIGNATURE, sizeof(PNG_SIGNATURE)) == 0)
    {
        return LoadPngTexture(bufData);
    }

    if (memcmp(header, JPG_SIGNATURE, sizeof(JPG_SIGNATURE)) == 0)
    {
        return LoadJpegTexture(bufData);
    }

    if (memcmp(header, GIF87_HEADER, 6) == 0 || memcmp(header, GIF89_HEADER, 6) == 0)
    {
        return 0;
    }

    if ((memcmp(header, WEBP_RIFF, 4) == 0) && (memcmp(header + 8, WEBP_WEBP, 4) == 0))
    {
        return 0;
    }

    return 0;
}